package com.javase.algorithm.leetcode;

import com.javase.algorithm.leetcode.utils.Automaton;

/**
 * @author liyanhao
 * @Date 2022-11-22 10:54
 */
public class LC08 {
    public static void main(String[] args) {


        LC08 lc08 = new LC08();
        int i = lc08.myAtoi("4193 with words");
        System.out.println(i);

    }

    /**
     * 状态机
     *
     * @param s
     * @return
     */
    public int myAtoi(String s) {
        Automaton automaton = new Automaton();
        int length = s.length();
        for (int i = 0; i < length; ++i) {
            automaton.get(s.charAt(i));
        }
        return (int) (automaton.sign * automaton.ans);
    }

}











